package com.xiaomaoaixue.web.controller.wecom;

import com.xiaomaoaixue.common.core.exception.CustomException;
import com.xiaomaoaixue.common.core.web.controller.BaseController;
import com.xiaomaoaixue.common.core.web.domain.AjaxResult;
import com.xiaomaoaixue.common.log.annotation.Log;
import com.xiaomaoaixue.common.log.enums.BusinessType;
import com.xiaomaoaixue.wecom.service.IWeDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企业微信组织架构相关Controller
 *
 * @author ruoyi
 * @date 2020-09-01
 */
@Api(tags = "微信组织架构相关接口")
@RestController
@RequestMapping("/wecom/department")
public class WeDepartmentController extends BaseController {

    @Autowired
    IWeDepartmentService weDepartmentService;

    /**
     * 同步成员
     *
     * @return
     */
    @ApiOperation("同步部门")
    @Log(title = "同步部门", businessType = BusinessType.OTHER)
    @GetMapping({"/sync"})
    public AjaxResult synchWeDepartment() {
        try {
            weDepartmentService.synchWeDepartment();
        }catch (CustomException e){
            return AjaxResult.error(e.getMessage());
        }

        return AjaxResult.success();
    }


}
